<?php
/**
 * File from WEBO Video Transmuter, WEBO Software (http://www.webogroup.com/)
 * Provides HTML for file upload interface
 *
 **/
?><h1>WEBO Video Transmuter</h1><?php
	if (!$page_variables['wvt_error'] && ($page_variables['wvt_service_upload'] || $page_variables['wvt_local_upload'])) {
?><div class="wvt_success">Your video sent to encoding</div><?php
	} elseif ($page_variables['wvt_error']) {
?><div class="wvt_error"><?php
		switch ($page_variables['wvt_error']) {
			case '1':
				echo 'Can\'t upload file, increase maximum file upload limit (PHP., or POST, or Apache, or nginx)';
				break;
			case '2':
				echo 'Can\'t get URL. Please check URL and curl existence';
				break;
			case '3':
				echo 'Can\'t get local file. Please check it\'s existence';
				break;
			case '4':
				echo 'File conversion error, please write to dev';
				break;
			case '5':
				echo 'File type isn\'t supported';
				break;
			case '11':
				echo 'Can\'t create video folder ' . $page_variables['wvt_videodir'] . '. Is it writable?';
				break;
			case '12':
				echo 'Can\'t run ffmpeg library ' . $page_variables['wvt_ffmpeg'] . '. Is it installed and executable?';
				break;
		}
?></div><?php
	}
?><h2>Select video file</h2><a href="javascript:(function(){var a=document.getElementById('wvt_config').style;a.display=a.display=='block'?'none':'block'}())">Configure</a><form id="wvt_config" action="" method="POST" style="display:none"><div class="wvt_form_item"><label for="wvt_rootdir" class="wvt_label">Document root</label><input class="wvt_input wvt_config_input" name="wvt_rootdir" id="wvt_rootdir" value="<?php
	echo $page_variables['wvt_rootdir'];
?>"/><span class="wvt_form_comment">Please enter full path to document root, i.e. /var/www/</span></div><div class="wvt_form_item"><label for="wvt_videodir" class="wvt_label">Video folder</label><input class="wvt_input wvt_config_input" name="wvt_videodir" id="wvt_videodir" value="<?php
	echo $page_variables['wvt_videodir'];
?>"/><span class="wvt_form_comment">Full path to directory with videos, i.e. /var/www/video/</span></div><div class="wvt_form_item"><label for="wvt_host" class="wvt_label">Website host</label><input class="wvt_input wvt_config_input" name="wvt_host" id="wvt_host" value="<?php
	echo $page_variables['wvt_host'];
?>"/><span class="wvt_form_comment">Website address without http://, i.e www.website.com</span></div><div class="wvt_form_item"><label for="wvt_api" class="wvt_label">Token</label><input class="wvt_input wvt_config_input" name="wvt_api" id="wvt_api" value="<?php
	echo $page_variables['wvt_api'];
?>"/><span class="wvt_form_comment">Enter your authorization token for Huideo service</span></div><div class="wvt_form_item"><label for="wvt_ffmpeg" class="wvt_label">FFMpeg path:</label><input class="wvt_input wvt_config_input" name="wvt_ffmpeg" id="wvt_ffmpeg" value="<?php
	echo $page_variables['wvt_ffmpeg'];
?>"/><span class="wvt_form_comment">or path to your own FFMPEG binary, i.e. /usr/bin/ffmpeg</span></div><div class="wvt_form_item"><label for="wvt_lang" class="wvt_label">Admin language:</label><input class="wvt_input wvt_config_input" name="wvt_lang" id="wvt_lang" value="<?php
	echo $page_variables['wvt_lang'];
?>"/><span class="wvt_form_comment">en or ru</span></div><div class="wvt_form_item"><label for="wvt_lang" class="wvt_label">Admin e-mail:</label><input class="wvt_input wvt_config_input" name="wvt_email" id="wvt_email" value="<?php
	echo $page_variables['wvt_email'];
?>"/><span class="wvt_form_comment">just to notify about converting progress</span></div><div class="wvt_form_item wvt_submit"><input type="hidden" name="wvt_submit" value="1"/><input type="hidden" name="wvt_config" value="1"/><input type="submit" name="wvt_submit" value="Save settings"/></div></form><p>Choose video file to encode</p><form action="" method="POST" id="wvt_video" enctype="multipart/form-data"><?php
	if ($page_variables['wvt_file_uploads']) {
?><div class="wvt_form_item"><label for="wvt_file" class="wvt_label">From desktop (max size: <?php
		echo $page_variables['wvt_max_size'];
?>)</label><input class="wvt_input wvt_input_file" type="file" name="wvt_file" id="wvt_file"/></div><?php
	}
	if ($page_variables['wvt_curl']) {
?><div class="wvt_form_item"><label for="wvt_url" class="wvt_label">via URL</label><input class="wvt_input" name="wvt_url" id="wvt_url" value="<?php
		echo htmlspecialchars($page_variables['wvt_url']);
?>"/></div><?php
	}
?><div class="wvt_form_item"><label for="wvt_path" class="wvt_label">or local file</label><input class="wvt_input" name="wvt_path" id="wvt_path" value="<?php
	echo htmlspecialchars($page_variables['wvt_path']);
?>"/></div><div class="wvt_form_item"><label for="wvt_path" class="wvt_label">Description</label><input class="wvt_input wvt_config_input" name="wvt_description" id="wvt_description" value="<?php
	echo htmlspecialchars($page_variables['wvt_description']);
?>"/><span>Short comment for you only</span></div><div class="wvt_form_item wvt_submit"><input type="hidden" name="wvt_submit" value="1"/><input class="wvt_input_submit" type="submit" name="wvt_submit" value="Push video!"/></div></form><?php
	if ($page_variables['wvt_service_upload'] && !$page_variables['wvt_ffmpeg']) {
?><img src="http://wvt.webogroup.com/api/?key=<?php
		echo $page_variables['wvt_api'];
?>&amp;file=<?php
		echo urldecode($page_variables['wvt_file']);
?>&amp;action=upload&amp;host=<?php
		echo urldecode($page_variables['wvt_host']);
?>" style="display:none" width="1" height="1" alt="Files upload ping"/><?php
	}
	if ($page_variables['wvt_local_upload'] && $page_variables['wvt_ffmpeg']) {
?><img src="<?php
		echo $page_variables['wvt_converter'];
?>?path=<?php
		echo $page_variables['wvt_file'];
?>&amp;type=1" style="display:none" width="1" height="1" alt="Files local ping"/><img src="<?php
		echo $page_variables['wvt_converter'];
?>?path=<?php
		echo $page_variables['wvt_file'];
?>&amp;type=2" style="display:none" width="1" height="1" alt="Files local ping"/><img src="<?php
		echo $page_variables['wvt_converter'];
?>?path=<?php
		echo $page_variables['wvt_file'];
?>&amp;type=3" style="display:none" width="1" height="1" alt="Files local ping"/><?php
	}
	if (count($page_variables['wvt_video'])) {
?><ul class="wvt_video"><?php
		foreach ($page_variables['wvt_video'] as $k => $v) {
			if ($v['thumb']) {
?><li class="wvt_video_item"><img class="wvt_video_img" src="<?php
				echo $v['thumb'];
?>"/><h3 class="wvt_video_title"><?php
				echo $v['description'] ? $v['description'] : $v['name'];
?></h3><textarea cols="35" rows="3" class="wvt_video_code" onclick="this.select()" title="Copy to clipboard, Ctrl+C">[video src="<?php
				echo $v['name'];
?>" width=320 height=240]</textarea></li><?php
			}
		}
?></ul><?php
	}
?>